INCLUDE_DIRECTORIES(
include
depends/tinyxml
depends/lua/include
depends/tolua++
depends/protobuf
depends/PolyVox/library/PolyVoxCore/include
depends/PolyVox/library/PolyVoxUtil/include
depends/SkyX/SkyX/Include
depends/ogre-paged/include
${CMAKE_CURRENT_BINARY_DIR}/depends/ogre-paged
depends/zlib
gui/pkg
)

ADD_SUBDIRECTORY(depends/protobuf)
ADD_SUBDIRECTORY(depends/PolyVox)
ADD_SUBDIRECTORY(depends/ogre-paged)
ADD_SUBDIRECTORY(depends/zlib)
ADD_SUBDIRECTORY(depends/SkyX)

SET(PROJECT_HDRS
include/Overseer.h
include/GUIManager.h
include/InputManager.h
include/State.h
include/TitleScreenState.h
include/LoadingState.h
include/FileDialog.h
include/GeometryGenerator.h
include/PolyVoxGenerator.h
include/VisualizerState.h
include/VisCamController.h
include/MaterialDictionary.h
include/PlantDictionary.h
include/Settings.h
${CMAKE_CURRENT_SOURCE_DIR}/gui/pkg/LuaInterface.h
)

SET(PROJECT_SRCS
main.cpp
Overseer.cpp
GUIManager.cpp
InputManager.cpp
TitleScreenState.cpp
LoadingState.cpp
FileDialog.cpp
PolyVoxGenerator.cpp
VisualizerState.cpp
VisCamController.cpp
MaterialDictionary.cpp
PlantDictionary.cpp
Settings.cpp

${CMAKE_CURRENT_SOURCE_DIR}/gui/pkg/LuaInterface.cpp

depends/tinyxml/tinystr.cpp
depends/tinyxml/tinyxml.cpp
depends/tinyxml/tinyxmlerror.cpp
depends/tinyxml/tinyxmlparser.cpp
)

SET(PROJECT_PROTOS
${CMAKE_CURRENT_SOURCE_DIR}/proto/Tile.proto
${CMAKE_CURRENT_SOURCE_DIR}/proto/Block.proto
${CMAKE_CURRENT_SOURCE_DIR}/proto/Map.proto
${CMAKE_CURRENT_SOURCE_DIR}/proto/Material.proto
${CMAKE_CURRENT_SOURCE_DIR}/proto/Plant.proto
)

STRING(REPLACE ".proto" ".pb.cc;" PROJECT_PROTO_SRCS ${PROJECT_PROTOS})
STRING(REPLACE ".proto" ".pb.h;" PROJECT_PROTO_HDRS ${PROJECT_PROTOS})

LIST(APPEND PROJECT_HDRS ${PROJECT_PROTO_HDRS})
LIST(APPEND PROJECT_SRCS ${PROJECT_PROTO_SRCS})

LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})

ADD_CUSTOM_COMMAND(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/gui/pkg/LuaInterface.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gui/pkg/LuaInterface.h
    COMMAND ${CEGUI_TOLUA_BIN} -H LuaInterface.h -o LuaInterface.cpp Interface.pkg
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gui/pkg
)

ADD_CUSTOM_COMMAND(
    OUTPUT ${PROJECT_PROTO_SRCS} ${PROJECT_PROTO_HDRS}
    COMMAND protoc-bin -I=${CMAKE_CURRENT_SOURCE_DIR}/proto/ --cpp_out=${CMAKE_CURRENT_SOURCE_DIR}/proto/ ${PROJECT_PROTOS}
    DEPENDS protoc-bin ${PROJECT_PROTOS}
)

IF(UNIX)
    SET(CMAKE_CXX_FLAGS "-std=c++0x -O2 ${CMAKE_CXX_FLAGS}")
ENDIF()

ADD_EXECUTABLE(Overseer ${PROJECT_SRCS})
TARGET_LINK_LIBRARIES(Overseer ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${CEGUI_LIBRARY} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${LUA_LIBRARIES} protobuf zlib PagedGeometry PolyVoxCoreStatic SkyX)
